package logic

import (
	"MyBlogv2/Servers/WebSiteInfo/internal/svc"
	"MyBlogv2/Servers/WebSiteInfo/webSiteInfo"
	"MyBlogv2/blog-common/HttpCode"
	"MyBlogv2/blog-common/models"
	"context"

	"github.com/zeromicro/go-zero/core/logx"
)

type GetBannersLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewGetBannersLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetBannersLogic {
	return &GetBannersLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *GetBannersLogic) GetBanners(in *webSiteInfo.WebSiteInfoRequest) (*webSiteInfo.GetBannersResponse, error) {
	var paths []string
	models.Db.Model(new(models.Banners)).Select("path").Find(&paths)
	return &webSiteInfo.GetBannersResponse{
		Code: int64(HttpCode.SUCCESS),
		Data: paths,
	}, nil
}
